<%@ page import="br.edu.ufam.controleAcesso.*" %>
<html>
    <head>
        <title>SISAVAC - UFAM</title>
        <link rel="stylesheet" href="${resource(dir:'css',file:'main.css')}" />
        <link rel="shortcut icon" href="${resource(dir:'images',file:'favicon.ico')}" type="image/x-icon" />        
        <g:javascript library="jquery/jquery-ui-1.8.9/js/jquery-1.4.4.min" />
        <g:javascript library="jquery/jquery-ui-1.8.9/js/jquery-ui-1.8.9.custom.min" />
        <g:javascript library="jquery/jquery-ui-1.8.9/development-bundle/ui/i18n/jquery.ui.datepicker-pt-BR" />
        <link rel="stylesheet" href="${createLinkTo(dir:'js/jquery/jquery-ui-1.8.9/css/cupertino',file:'jquery-ui-1.8.9.custom.css')}" />
        <g:javascript library="jquery/jquery-ui-1.8.9/js/jquery-ui-timepicker-addon" />
        <g:javascript library="jquery/validate/jquery.validate.min" />
        <g:javascript library="jquery/validate/additional-methods" />
        <g:javascript library="jquery/validate/localization/messages_ptbr" />
        <g:javascript library="jquery/masked-input/jquery.maskedinput-1.2.2.min" />
        <g:javascript library="jquery/priceformat/jquery.price_format.1.3" />
        <g:javascript library="jquery/jqDock.v1_6/jquery.jqDock.min" />
        <g:javascript library="application" />
        <g:layoutHead />
        <script type="text/javascript">

          var _gaq = _gaq || [];
          _gaq.push(['_setAccount', 'UA-22156215-6']);
          _gaq.push(['_trackPageview']);

          (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
          })();

        </script>
    </head>
    <body>
        <div id="spinner" class="spinner" style="display:none;">
            <img src="${resource(dir:'images',file:'spinner.gif')}" alt="${message(code:'spinner.alt',default:'Loading...')}" />
        </div>
      <div>
        <a href="${createLinkTo(dir:'')}"><img src="${resource(dir:'images',file:'logo_titulo.jpg')}" alt="SISPUNTU" border="0" style="margin-top: 1px;" /></a></div>
        <div id="dock" class="nav" align="center">
          <g:link controller="home" action="index" alt="Home" title="Home" style="margin:3px;"><img src="${resource(dir:'images/shortcuts',file:'home.png')}" /></g:link>
          <g:each in="${session?.aplicacoes}" var="app">
              <g:if test="${app.controle == 'usuario'}">
                <g:link controller="usuario" action="index" alt="Usuários" title="Usuários" style="margin:3px;"><img src="${resource(dir:'images/shortcuts',file:'usuario.png')}" /></g:link>
              </g:if>
              <g:if test="${app.controle == 'grupo'}">
                <g:link controller="grupo" action="index" alt="Grupos" title="Grupos" style="margin:3px;"><img src="${resource(dir:'images/shortcuts',file:'grupo.png')}" /></g:link>
              </g:if>
              <g:if test="${app.controle == 'venda'}">
                <g:link controller="venda" action="index" alt="Venda" title="Venda" style="margin:3px;"><img src="${resource(dir:'images/shortcuts',file:'coins.png')}" /></g:link>
              </g:if>
          </g:each>
          <g:link controller="home" action="logout" alt="Sair" title="Sair" style="margin:3px;"><img src="${resource(dir:'images/shortcuts',file:'exit.png')}" /></g:link>
        </div>
        <% 
          def usuario = Usuario.get(session?.usuario)          
        %>
        <div id="user-information" style="position: absolute; top: 73px; padding-left: 5px; display: table-cell; font-size: 10px;">
          Bem-vindo(a), <strong>${usuario?.nome}</strong>.<br/>
          Sessão iniciada em <strong>${session?.dtIniSession?.format("dd/MM/yyyy")} às ${session?.dtIniSession?.format("HH:mm")}</strong>.
        </div>
        <%
          def menus = [] as Set
          session?.aplicacoes.each {
            menus << it.menu
          }
        %>
        <table id="main-panel" height="100%" cellspacing="0" cellpadding="0" style="border-width:0;">
          <tbody>
            <tr>
              <td id="panel-menu" style="width:210px; padding: 3px;">
                    <div id="accordion">
                      <h3><a href="#">Home</a></h3>
                        <div>
                          <h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"><g:link style="padding-left:10px;" class="list" controller="home" action="index">Principal</g:link></h3>
                          <h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"><g:link style="padding-left:10px;" class="list" controller="home" action="alterarSenha">Alterar Senha</g:link></h3>
                          <h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"><g:link style="padding-left:10px;" class="list" controller="home" action="logout">Sair</g:link></h3>
                        </div>
                      <g:each in="${menus}" var="menu">
                        <h3><a href="#">${menu?.descricao}</a></h3>
                        <div>
                          <g:each in="${session?.aplicacoes}" var="app">
                            <g:if test="${menu.id == app.menu.id && app.visivel}">
                              <h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"><g:link style="padding-left:10px;" class="list" controller="${app?.controle}" action="index">${app?.descricao}</g:link></h3>
                            </g:if>
                          </g:each>
                        </div>
                      </g:each>
                    </div>
              </td>
              <td>
                <div id="panel-content" style="padding: 3px 0px 0px 5px; border-left:1px solid #cccccc;">
                  <g:layoutBody />
                </div>
              </td>
            </tr>
          </tbody>
        </table>
      <div class="ui-state-focus" style="padding:5px; clear:both;" align="center">© Gerência de Desenvolvimento de Sistemas - CPD - UFAM</div>
    </body>
</html>